using System;
using System.Collections;
using System.Html;
using System.Runtime.CompilerServices;
using Awaiter;
using Nsb.Classes;
using Yoshi.Classes;
using YoshiFlowCheck.Classes;
using jQueryApi;

namespace YoshiFlowCheck
{
    [IgnoreNamespace]
    public class AlivenessCheck : Actor
    {
        private readonly Dictionary _helpDict =
            new Dictionary(
                "class", "AlivenessCheck",
                "duration", 10000
                )
                                    ;

        private Help _help;


        public AlivenessCheck(Action fn)
        {
            new Await()
                .LoadCss("Scripts/Css/AlivenessCheck.css")
                .AddDx(
                    delegate
                    {
                        Element = jQuery.FromHtml("<div id='AlivenessCheck' class='FlowPath'/>")
                            .AddClass(GetType().Name + " AboveHider")
                            .AppendTo("body")
                            ;

                        _help = new Help(Element)
                            .After(5000, _helpDict)
                            .Every(30000, _helpDict)
                            ;

                        new PathReader(new AlivenessMap().End(), new Dictionary("@done", fn), _help)
                            .AppendTo(Element)
                            ;

                        Element.Plugin<Jewl>().Position(new Dictionary("my", "center", "at", "center", "of", Window.Self));
                        Element.Plugin<Jewl>().Position(new Dictionary("my", "top", "at", "top", "of", Window.Self, "offset", "0 200", "collision", "fit fit"));
                    }
                )
                .AddAw(HiderAw, true)
                .Commit();
        }
    }
}